﻿<UserControl x:Class="JayDev.MediaScribe.View.CourseUseView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d"
             xmlns:nmControls="clr-namespace:JayDev.MediaScribe.View.Controls"
             xmlns:MediaScribeCommon="clr-namespace:JayDev.MediaScribe.Common"
             xmlns:nmConverters="clr-namespace:JayDev.MediaScribe.Converters"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4"
             x:Name="CourseUseViewName"
             d:DesignHeight="419" d:DesignWidth="1388">
    <UserControl.Resources>
        <nmConverters:GridLengthValueConverter x:Key="gridLengthConverter" />
        <nmConverters:BooleanToVisibilityConverter 
                x:Key="BooleanToVisibilityConverterTrueIsVisible" 
                True="Visible" 
                False="Collapsed" />
        <nmConverters:BooleanToVisibilityConverter 
                x:Key="BooleanToVisibilityConverterTrueIsVisibleFalseIsHidden" 
                True="Visible" 
                False="Hidden" />
    </UserControl.Resources>
    <!--<Grid Background="#FFEFF5FF">-->
    <Grid Background="Transparent">
        <DockPanel Name="windowContents">
            <!--<nmControls:NavigationControl2 x:Name="navi"
                                                DockPanel.Dock="Top" />-->
            
            <nmControls:MediaControlsControl x:Name="mediaControls"
                                                   DockPanel.Dock="Bottom"
                                                   CurrentPlayTime="{Binding CurrentTrackPlayPosition}"
                                                   MaxPlayTime="{Binding CurrentTrackTotalLength}"
                                                   PlayPauseCommand="{Binding PlayPauseCommand}"
                                                   SeekToCommand="{Binding SeekToCommand}"
                                                   TrackTitle="{Binding CurrentTrackName}"
                                                   PlayStatus="{Binding PlayStatus}"
                                                   Volume="{Binding Volume, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                                   ToggleMuteCommand="{Binding ToggleMuteCommand}"
                                                   IsMuted="{Binding IsMuted}"
                                                   StopCommand="{Binding StopCommand}"
                                                   NextTrackCommand="{Binding NextTrackCommand}"
                                                   PrevTrackCommand="{Binding PrevTrackCommand}"
                                                   />

            <Border Background="#FFEEF6FF">
            <Grid Name="mainGrid">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="{Binding Path=LastEmbeddedVideoWidth, Mode=TwoWay, Converter={StaticResource gridLengthConverter}, TargetNullValue='300'}"/>
                    <ColumnDefinition Width="5"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>

                <Grid Name="leftGridColumn">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="{Binding Path=VirtualEmbeddedVideoHeight, Mode=TwoWay, Converter={StaticResource gridLengthConverter}, TargetNullValue='300'}" />
                        <RowDefinition Height="6" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                        <DockPanel Grid.Row="0" Background="LightGray" DockPanel.Dock="Top"  LastChildFill="True" Visibility="{Binding IsCurrentTrackVideo, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverterTrueIsVisibleFalseIsHidden}, UpdateSourceTrigger=PropertyChanged, FallbackValue=Visible}">
                        <!--<TextBlock DockPanel.Dock="Top">Video</TextBlock>
                        <DockPanel Name="videoControlHolder">-->
                            <nmControls:VideoControl x:Name="videoControl"
                                                           VideoPanelPointer="{Binding VideoPanelPointer, Mode=OneWayToSource}"
                                                           AspectRatio="{Binding CurrentTrackVideoAspectRatio}"
                                                           IsShowingVideo="{Binding IsCurrentTrackVideo}"
                                                           PlayPauseCommand="{Binding ToggleFullscreenCommand}"
                                                           EnableAutohideControls="False"/>
                        <!--</DockPanel>-->
                    </DockPanel>
                    <GridSplitter
            ResizeDirection="Rows" 
            Grid.Column="0"
            Grid.ColumnSpan="2"
            Grid.Row="1"
            Width="Auto" 
            Height="3"
            HorizontalAlignment="Stretch" 
            VerticalAlignment="Stretch" 
            Margin="0" DragCompleted="GridSplitter_DragCompleted_1"  Visibility="{Binding IsCurrentTrackVideo, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverterTrueIsVisible}, UpdateSourceTrigger=PropertyChanged, FallbackValue=Visible}" />

                    <DockPanel Grid.Row="2">
                        <!--<TextBlock Foreground="#FF3F3F3F" DockPanel.Dock="Top" Margin="5 0 0 5">Course Track List</TextBlock>-->
                            <nmControls:DoubleClickableDataGrid VerticalAlignment="Top" AutoGenerateColumns="False" LoadingRow="DataGrid_LoadingRow" x:Name="trackGrid" HeadersVisibility="All" CanUserAddRows="False"
                           CanUserSortColumns="False" CanUserReorderColumns="False" CanUserResizeRows="False" ItemsSource="{Binding Tracks}" Style="{StaticResource DataGridStyle1}"
                                                                 SelectionMode="Single"
                                                                 RowDoubleClickCommand="{Binding SelectTrackCommand,Mode=OneWay}"
                                                                 RowDoubleClickCommandParameter="{Binding SelectedItem, ElementName=trackGrid, Mode=OneWay}"
                                                                 HighlightItem="{Binding CurrentTrackName}">
                            <!-- Custom bit of logic - when we play a track, we want to highlight it. -->
                            <DataGrid.CellStyle>
                                <Style TargetType="DataGridCell" BasedOn="{StaticResource DataGridCellStyle1}">
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding Path=IsPlaying, UpdateSourceTrigger=PropertyChanged}" Value="True">
                                            <Setter Property="Background">
                                                <Setter.Value>
                                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                        <GradientStop Color="#FFDAC9FF" Offset="0"/>
                                                        <GradientStop Color="#FFAC7EFF" Offset="1"/>
                                                    </LinearGradientBrush>
                                                </Setter.Value>
                                            </Setter>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </DataGrid.CellStyle>




                                <DataGrid.Columns>
                                <DataGridTextColumn Header="Track"
                                            Width="*"
                                           Binding="{Binding StringDisplayValue}" 
                                           IsReadOnly="True"/>
                                <DataGridTextColumn Header="Length"
                                            Width="55"
                                           Binding="{Binding Length}" 
                                           IsReadOnly="True"/>
                            </DataGrid.Columns>
                            </nmControls:DoubleClickableDataGrid>
                    </DockPanel>
                </Grid>

                <GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" DragCompleted="GridSplitter_DragCompleted" />

                <DockPanel Grid.Column="2" VerticalAlignment="Top">
                    <nmControls:NotesGridControl x:Name="notesGrid"
                                                       PrepareNoteForEditCommand="{Binding PrepareNoteForEditCommand}"
                                                       NoteSavedCommand="{Binding NoteSavedCommand}"
                                                       Notes="{ Binding Notes, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                                       PlayNoteCommand="{Binding PlayNoteCommand}"
                                                       SetNoteStartTimeCommand="{Binding SetNoteStartTimeCommand}"
                                                       NoteEditCompletedCommand="{Binding NoteEditCompletedCommand}">
                    </nmControls:NotesGridControl>
                </DockPanel>
            </Grid>
            </Border>
        </DockPanel>
    </Grid>
</UserControl>
